package com.thinkgem.jeesite.modules.sys.web;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.modules.sys.entity.TbMpWalletStreamJYY;
import com.thinkgem.jeesite.modules.sys.service.TbMpWalletStreamJYYService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by jyy on 2016/10/22 0022.
 */

@Controller
@RequestMapping(value = "${adminPath}/sys/mpWalletStream")
public class TbMpWalletController {

    @Autowired
    private TbMpWalletStreamJYYService tbMpWalletStreamJYYService;

    // 用户充值记录信息
    @RequestMapping(value = "userMpWalletStream")
    public String userMpWalletStream(TbMpWalletStreamJYY tbMpWalletStreamJYY, HttpServletRequest request, HttpServletResponse response, Model model) {

        Page<TbMpWalletStreamJYY> tbMpWalletStreamJYYPage = tbMpWalletStreamJYYService.findUserRechargeByPage(new Page<TbMpWalletStreamJYY>(request, response), tbMpWalletStreamJYY);

        String flag = request.getParameter("userOrShop");
        // 用户充值记录信息
        if ("0".equals(flag)) {
         tbMpWalletStreamJYYPage = tbMpWalletStreamJYYService.findUserRechargeByPage(new Page<TbMpWalletStreamJYY>(request, response), tbMpWalletStreamJYY);
        }

        //商户充值记录
        if ("1".equals(flag)) {
           tbMpWalletStreamJYYPage = tbMpWalletStreamJYYService.findShopRechargeByPage(new Page<TbMpWalletStreamJYY>(request, response), tbMpWalletStreamJYY);
        }
        if(tbMpWalletStreamJYYPage.getList().size()==0){
            model.addAttribute("message1","无查询结果");
        }

        model.addAttribute("tbMpWalletStreamJYYPage", tbMpWalletStreamJYYPage);
        model.addAttribute("userOrShop", flag);

        return "modules/sys/userMpWalletStreamRecharge";
    }


}
